home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / Rsrc Compression Example / rsrcCompress.r < prev    next >
Encoding:
Text File  |  1994-11-15  |  16.3 KB  |  482 lines  |  [TEXT/MPS ]

  1. //
  2. //    rsrcCompress.r
  3. //
  4. //        This installer script source demonstrates use of InstaCompOne 
  5. //        resource archives, split resources, the InstaCompOneTool 
  6. //        compression utility, and the FileAndRsrcSplitterTool.
  7. //
  8. //    How To Build the Script:
  9. //    
  10. //        To build installer script access "Build…" item within "Build" menu
  11. //        and enter the scriptName "rsrcCompress". To build the installer
  12. //        debugger version of the installer script enter the scriptname
  13. //        with the addition ".debug" ( "rsrcCompress.debug" ).
  14. //
  15. //        There must be a copy of the file "InstaCompOneSCExt.rsrc"
  16. //        that has been renamed to "rsrcCompress.scx" included in this
  17. //        folder as well. This file will automatically be copied and
  18. //        renamed ( from the InstaCompOne folder in the SDK ) when the
  19. //        makefile for this example is run.
  20. //
  21. //    What this example does :
  22. //
  23. //        Four Custom Install options are provided to the user:
  24. //
  25. //        1) Installs a copy of the file TeachText onto the selected target 
  26. //        volume ( without use of compression or file splitting ). This
  27. //        installed file is included only as the target of the other three
  28. //        Custom Install options. 
  29. //
  30. //        NOTE: Resource installation can be specified as either requiring
  31. //        an existing target file, or not requiring an existing target file.
  32. //        All resource installation options in this example have been set
  33. //        so that a target is required. If you try the resource installation
  34. //        options ( 2), 3), 4) ) without first installing the first option, 
  35. //        an error dialog will be provided and installation will be prevented
  36. //        from continuing.
  37. //
  38. //        2) Install resource item of type 'STR#' and ID 9000. Adds the 
  39. //        'STR#' resource item to the TeachText file installed in option 1).
  40. //        This option demonstrates resource compression.
  41. //
  42. //        3) Install resource item of type 'STR#' and ID 9100. Adds the 
  43. //        'STR#' resource item to the TeachText file installed in option 1).
  44. //        This option demonstrates resource splitting and compression.
  45. //
  46. //        4) Install resource item of type 'STR#' and ID 9200. Adds the 
  47. //        'STR#' resource item to the TeachText file installed in option 1).
  48. //        This option demonstrates resource splitting.
  49. //
  50. //
  51. //        All target files from example installations are placed in a 
  52. //        folder called ":InstaComp Rsrc Testing:" on the root folder of 
  53. //        the target volume of installation.
  54. //
  55. //    NOTE: InstaCompOne can be used to split and compress files and 
  56. //    fonts in addition to resources, but this example deals only with 
  57. //    splitting and compressing resources. 
  58. //
  59. //  NOTE: It's best to store the split or compressed resource as type
  60. //    'part', instead of the original type, to prevent errors due to
  61. //    the assumption that if it's of a certain type it must be complete.
  62. //
  63. //     NOTE: When using InstaCompOne compression and splitting, simply enter 241
  64. //     as the value for the atom extender ( 'inex' ) in the next to last field
  65. //     of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
  66. //     decompressed. There is no need to declare an 'inex' resource within the
  67. //     installer script source. An 'inex' resource definition is contained in
  68. //     the InstaCompOne resource file that is included at the top of this file.
  69. //
  70. //    NOTE: When splitting files or resources without using compression
  71. //    pass a value of 0 ( zero ) for the atom extender in the atom extender
  72. //    field of the atom ( 'infa', 'inra', 'inff' ).
  73. //
  74. //
  75. //        mark young • 08/17/94
  76. //
  77. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  78. //
  79.  
  80. #include "InstallerTypes.r"
  81.  
  82. // Include the InstaCompOne atom extender stuff
  83. // making sure not to add their version resource
  84. // to our installer script. Also, since this include
  85. // is a resource include instead of a #include, it is
  86. // not actually a pre-processor thing, and won't be effected
  87. // by a -i option within the rez line in the makefile. 
  88. include ":::InstaCompOne 1.0:InstaCompOneAtomExt.rsrc" NOT 'vers';
  89.  
  90.  
  91. // • packages
  92.  
  93. // package that installs TeachText - no compression or splitting used
  94. // this file is intended only as the target for the following packages
  95. // that will install resource items into the application TeachText
  96. resource 'inpk' (100) {
  97.     format0 {
  98.         showsOnCustom,
  99.         notRemovable,
  100.         dontForceRestart,
  101.         0,
  102.         0,
  103.         "Install TeachText [ DO THIS FIRST !! SO RSRC'S CAN BE ADDED TO IT ]",
  104.         {    
  105.         'infa', 1000;
  106.         },
  107.     }
  108. };
  109.  
  110. // package that demonstrates decompressing one resource item 
  111. // and adding the result to one target file
  112. resource 'inpk' (200) {
  113.     format0 {
  114.         showsOnCustom,
  115.         removable,
  116.         dontForceRestart,
  117.         0,
  118.         0,
  119.         "Add rsrc item 'STR#' (9000) to TeachText [ compress rsrc example ]",
  120.         {    
  121.         'inra', 2000;
  122.         },
  123.     }
  124. };
  125.  
  126. // package that demonstrates decompressing two resource item pieces 
  127. // and adding the result to one target file
  128. resource 'inpk' (300) {
  129.     format0 {
  130.         showsOnCustom,
  131.         removable,
  132.         dontForceRestart,
  133.         0,
  134.         0,
  135.         "Add rsrc item 'STR#' (9100) to TeachText [ split,compress rsrc example ]",
  136.         {    
  137.         'inra', 3000;
  138.         },
  139.     }
  140. };
  141.  
  142. // package that demonstrates joining two resource item pieces 
  143. // and adding the result to one target file
  144. resource 'inpk' (400) {
  145.     format0 {
  146.         showsOnCustom,
  147.         removable,
  148.         dontForceRestart,
  149.         0,
  150.         0,
  151.         "Add rsrc item 'STR#' (9200) to TeachText [ split rsrc example ]",
  152.         {    
  153.         'inra', 4000;
  154.         },
  155.     }
  156. };
  157.  
  158.  
  159. // • file atoms
  160.  
  161. // simple installation of TeachText application ( no compression, no splitting )
  162. resource 'infa' (1000) {
  163.     format1 {
  164.         deleteWhenRemoving,                //  Delete on deinstall
  165.         deleteWhenInstalling,            //  Remove preexisting
  166.         copy,                            //  Copy on Install
  167.         dontIgnoreLockedFile,            //  Respect file locking
  168.         dontSetFileLocked,                //  Leave installed file unlocked
  169.         useSrcCrDateToCompare,            //  Use creation date for compare
  170.         srcNeedNotExist,                //  Create a new file if necessary
  171.         rsrcForkInRsrcFork,                //  Resource stuff in Resource fork
  172.         leaveAloneIfNewer,                //  Do not update a newer file
  173.         updateExisting,                    //  Update an existing file
  174.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  175.         rsrcFork,                        //  Copy resource fork
  176.         dataFork,                        //  Copy data fork
  177.         
  178.         0,                    // TARGET - size ( filled in by ScriptCheck )
  179.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  180.         10000,                // TARGET - file spec ( 'infs' )
  181.         {    
  182.             11000,            // SOURCE - file spec ( 'infs' )
  183.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  184.             0                // RSRC fork - size ( filled in by ScriptCheck )
  185.         },    
  186.         
  187.         0x0,                // SOURCE - version number for comparisons
  188.                             // value of 0x0 specifies not to perform version comparison
  189.                             
  190.         0,                    // 'invc' code resource - version comparison routine 
  191.                             // ( none used here )
  192.         
  193.         0,                    // 'inex' resource definition for atom extender
  194.                             // • #241 is for built in InstaCompOne extender
  195.                             // NO COMPRESSION USED IN THIS EXAMPLE
  196.                             
  197.         "TeachText"            // file atom description
  198.     }
  199. };
  200.  
  201.  
  202. // • resource atoms
  203.  
  204. // installation of a compressed resource item to target file
  205. resource 'inra' (2000) {
  206.     format1 {
  207.         deleteWhenRemoving,                //  Delete on deinstall
  208.         deleteWhenInstalling,            //  Remove preexisting
  209.         copy,                            //  Copy on Install
  210.         leaveAloneIfNewer,                //  Do not update a newer file
  211.  
  212.         tgtRequired,                    //  Target file must already exist
  213.                                         //  • NOTE - this is the option
  214.                                         //  that prevents installation if
  215.                                         //  the target file to add the rsrc
  216.                                         //     item to does not already exist.
  217.                                         //    To create a new "empty" file
  218.                                         //    before adding the rsrc item
  219.                                         //  change the flag to 'noTgtRequired'
  220.                                         
  221.         updateExisting,                    //  Update an existing file
  222.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  223.         dontIgnoreProtection,            //  Respect file locking
  224.         srcNeedExist,                    //  Source file must exist
  225.         byID,                            //  Use rsrc ID instead of name
  226.         nameNeedNotMatch,                //  Ignored when using 'byID'
  227.         
  228.         0,                    // TARGET - total resource size after installation
  229.         10000,                // TARGET - file spec ( 'intf' )
  230.         'STR#',                // TARGET - resource type 
  231.         9000,                // TARGET - resource ID
  232.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  233.         "",                    // TARGET - resource name 
  234.         {    
  235.             12000,            // SOURCE - file spec ( 'infs' )
  236.             'part',            // SOURCE - resource type
  237.             9000,            // SOURCE - resource ID
  238.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  239.             "",                // SOURCE - resource name
  240.         },    
  241.         
  242.         0x0,                // SOURCE - version number for comparisons
  243.                             // value of 0x0 specifies not to perform version comparison
  244.                             
  245.         0,                    // 'invc' code resource - version comparison routine 
  246.                             // ( none used here )
  247.         
  248.         241,                // 'inex' resource definition for atom extender
  249.                             // • 241 is for built in InstaCompOne extender
  250.  
  251.         "",                    // resource atom description                    
  252.     }
  253. };
  254.  
  255.  
  256. // installation of a split and compressed resource item to target file
  257. resource 'inra' (3000) {
  258.     format1 {
  259.         deleteWhenRemoving,                //  Delete on deinstall
  260.         deleteWhenInstalling,            //  Remove preexisting
  261.         copy,                            //  Copy on Install
  262.         leaveAloneIfNewer,                //  Do not update a newer file
  263.  
  264.         tgtRequired,                    //  Target file must already exist
  265.                                         //  • NOTE - this is the option
  266.                                         //  that prevents installation if
  267.                                         //  the target file to add the rsrc
  268.                                         //     item to does not already exist.
  269.                                         //    To create a new "empty" file
  270.                                         //    before adding the rsrc item
  271.                                         //  change the flag to 'noTgtRequired'
  272.                                         
  273.         updateExisting,                    //  Update an existing file
  274.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  275.         dontIgnoreProtection,            //  Respect file locking
  276.         srcNeedExist,                    //  Source file must exist
  277.         byID,                            //  Use rsrc ID instead of name
  278.         nameNeedNotMatch,                //  Ignored when using 'byID'
  279.         
  280.         0,                    // TARGET - total resource size after installation
  281.         10000,                // TARGET - file spec ( 'infs' )
  282.         'STR#',                // TARGET - resource type 
  283.         9100,                // TARGET - resource ID
  284.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  285.         "",                    // TARGET - resource name 
  286.         {    
  287.             13000,            // SOURCE - file spec ( 'infs' )
  288.             'part',            // SOURCE - resource type
  289.             9100,            // SOURCE - resource ID
  290.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  291.             "",                // SOURCE - resource name
  292.  
  293.             13001,            // SOURCE - file spec ( 'infs' )
  294.             'part',            // SOURCE - resource type
  295.             9101,            // SOURCE - resource ID
  296.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  297.             "",                // SOURCE - resource name
  298.         },    
  299.         
  300.         0x0,                // SOURCE - version number for comparisons
  301.                             // value of 0x0 specifies not to perform version comparison
  302.                             
  303.         0,                    // 'invc' code resource - version comparison routine 
  304.                             // ( none used here )
  305.         
  306.         241,                // 'inex' resource definition for atom extender
  307.                             // • #241 is for built in InstaCompOne extender
  308.                             
  309.         "",                    // resource atom description                    
  310.     }
  311. };
  312.  
  313.  
  314. // installation of a split resource to target file
  315. // • InstaCompOne atom extender not need for non-compressed items
  316. resource 'inra' (4000) {
  317.     format1 {
  318.         deleteWhenRemoving,                //  Delete on deinstall
  319.         deleteWhenInstalling,            //  Remove preexisting
  320.         copy,                            //  Copy on Install
  321.         leaveAloneIfNewer,                //  Do not update a newer file
  322.  
  323.         tgtRequired,                    //  Target file must already exist
  324.                                         //  • NOTE - this is the option
  325.                                         //  that prevents installation if
  326.                                         //  the target file to add the rsrc
  327.                                         //     item to does not already exist.
  328.                                         //    To create a new "empty" file
  329.                                         //    before adding the rsrc item
  330.                                         //  change the flag to 'noTgtRequired'
  331.                                         
  332.         updateExisting,                    //  Update an existing file
  333.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  334.         dontIgnoreProtection,            //  Respect file locking
  335.         srcNeedExist,                    //  Source file must exist
  336.         byID,                            //  Use rsrc ID instead of name
  337.         nameNeedNotMatch,                //  Ignored when using 'byID'
  338.         
  339.         0,                    // TARGET - total resource size after installation
  340.         10000,                // TARGET - file spec ( 'infs' )
  341.         'STR#',                // TARGET - resource type 
  342.         9200,                // TARGET - resource ID
  343.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  344.         "",                    // TARGET - resource name 
  345.         {    
  346.             14000,            // SOURCE - file spec ( 'infs' )
  347.             'part',            // SOURCE - resource type
  348.             9200,            // SOURCE - resource ID
  349.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  350.             "",                // SOURCE - resource name
  351.  
  352.             14001,            // SOURCE - file spec ( 'infs' )
  353.             'part',            // SOURCE - resource type
  354.             9201,            // SOURCE - resource ID
  355.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  356.             "",                // SOURCE - resource name
  357.         },    
  358.         
  359.         0x0,                // SOURCE - version number for comparisons
  360.                             // value of 0x0 specifies not to perform version comparison
  361.                             
  362.         0,                    // 'invc' code resource - version comparison routine 
  363.                             // ( none used here )
  364.         
  365.         0,                    // Atom Extender not needed for joining ( w/o compression )    
  366.         
  367.         "",                    // resource atom description                    
  368.     }
  369. };
  370.  
  371.  
  372.  
  373. // • file specs
  374.  
  375. // target file spec for decompressed "TeachText" application 
  376. // • no compression
  377. // NOTE: When a target spec is called from within a resource atom of
  378. // any kind ( 'inra', 'inrm', 'inr#' ), the type, creator, dates and
  379. // Finder attributes fields will only apply when creating a new file.
  380. resource 'intf' (10000) {
  381.     format1 {
  382.         noSearchForFile,                 // use default search path
  383.         
  384.         TypeCrNeedNotMatch,             // If this is set to TypeCrMustMatch
  385.                                         // then a file with a different type
  386.                                         // and creator than those specified
  387.                                         // below will not be updated.
  388.                                         // If this is set to TypeCrNeedNotMatch
  389.                                         // then type and creator of an existing
  390.                                         // target file are ignored.
  391.         
  392.         // The Type and Creator fields will be used to set the
  393.         // file's Type and Creator when a new file is created. 
  394.         'APPL',                         // TYPE for new file
  395.         'ttxt',                         // CREATOR for new file
  396.         
  397.         0,                                 // finder attribute flags
  398.                                         // filled by ScriptCheck is value is 0
  399.         
  400.         1,                                  // creation date for new file
  401.         1,                                  // modification date for new file
  402.                                         // NOTE: DATE values are filled
  403.                                         // by ScriptCheck if the value is 1
  404.                                             
  405.         0,                                 // search proc ID ( 'insp' ), none used
  406.         
  407.         ":InstaComp Rsrc Testing:TeachText"    // path to target file
  408.         }
  409.     };
  410.  
  411. // source file spec for compressed "TeachText" application 
  412. // • no compression
  413. resource 'infs' (11000) {
  414.     'APPL',                        // TYPE for file search
  415.     'ttxt',                        // CREATOR for file search
  416.     0x0,                        // creation DATE for source file
  417.     noSearchForFile,            // IGNORED in Installer 4.0.x
  418.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  419.     "Disk 1:TeachText"            // PATH to source file        
  420. };
  421.  
  422. // • compressed resource - file specs
  423.  
  424. // source file spec for archive • compressed resource
  425. resource 'infs' (12000) {
  426.     'ircp',                        // TYPE 
  427.     'kakc',                        // CREATOR 
  428.     0x0,                        // creation DATE for source file
  429.     noSearchForFile,            // IGNORED in Installer 4.0.x
  430.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  431.     "Disk 1:CompressedRsrcTome"        // PATH to source file        
  432. };
  433.  
  434. // • split and compressed resource - file specs
  435.  
  436. // source file spec for archive containing first piece 
  437. // • split resource fork with compression
  438. resource 'infs' (13000) {
  439.     'ircp',                        // TYPE 
  440.     'kakc',                        // CREATOR 
  441.     0x0,                        // creation DATE for source file
  442.     noSearchForFile,            // IGNORED in Installer 4.0.x
  443.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  444.     "Disk 1:SplitCompRsrcTome1"            // PATH to source file        
  445. };
  446.  
  447. // source file spec for archive containing second piece 
  448. // • split resource with compression
  449. resource 'infs' (13001) {
  450.     'ircp',                        // TYPE 
  451.     'kakc',                        // CREATOR 
  452.     0x0,                        // creation DATE for source file
  453.     noSearchForFile,            // IGNORED in Installer 4.0.x
  454.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  455.     "Disk 2:SplitCompRsrcTome2"            // PATH to source file        
  456. };
  457.  
  458. // • split resource - file specs
  459.  
  460. // source file spec for archive containing first piece 
  461. // • split resource
  462. resource 'infs' (14000) {
  463.     'rsrc',                        // TYPE 
  464.     'RSED',                        // CREATOR 
  465.     0x0,                        // creation DATE for source file
  466.     noSearchForFile,            // IGNORED in Installer 4.0.x
  467.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  468.     "Disk 1:SplitRsrcTome1"            // PATH to source file        
  469. };
  470.  
  471. // source file spec for archive containing second piece 
  472. // • split resource
  473. resource 'infs' (14001) {
  474.     'rsrc',                        // TYPE 
  475.     'RSED',                        // CREATOR 
  476.     0x0,                        // creation DATE for source file
  477.     noSearchForFile,            // IGNORED in Installer 4.0.x
  478.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  479.     "Disk 2:SplitRsrcTome2"            // PATH to source file        
  480. };
  481.  
  482.